import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

public class HJ67 {
    private static final AtomicInteger seq = new AtomicInteger();

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while ((str = br.readLine()) != null) {
            System.out.println(caculate(str));

        }
    }

    public static boolean caculate(String str) {
        String[] arr = str.split(" ");
        List<Integer> inputArr = new ArrayList<>();
        for (String numStr : arr) {
            inputArr.add(Integer.parseInt(numStr.trim()));
        }
        for (int i = 0; i < inputArr.size(); i++) {
            //随机取出一个元素
            int temp = inputArr.get(i);
            inputArr.remove(i);
            //如果匹配，则直接返回。否则，将取出的元素放入原先位置。
            // {2,1,10},7
            if (match(inputArr, temp)){
                return true;
            }else {
                inputArr.add(i, temp);
            }
        }
        return false;
    }

    public static boolean match(List<Integer> list, int temp) {
        if (list.size() > 0) {
            //遍历子集合，随机取出一个元素
            for (int i = 0; i < list.size(); i++) {
                int n = list.get(i);
                list.remove(i);
                if (match(list, temp * n) || match(list, temp + n) || match(list, temp - n))
                    return true;
                else if (temp % n == 0) {
                    if (match(list, temp / n)){
                        return true;
                    }
                }
                list.add(i, n);
            }
            return false;
        } else if (temp == 24) {
            return true;
        } else
            return false;
    }
}
